package cj.web.activity.controllers;

import java.util.List;

import net.paoding.rose.web.annotation.Path;
import net.paoding.rose.web.annotation.rest.Get;
import net.paoding.rose.web.annotation.rest.Post;
import net.paoding.rose.web.var.Model;
import net.sf.json.JSONObject;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import cj.utils.Base64;
import cj.web.activity.dao.SCUserApplicationDAO;
import cj.web.activity.domain.SCUserApplication;
import cj.web.admin.constants.MemuEnum;
import cj.web.marriage.domain.UserApplication;

@Path("/scuserApplication")
public class SCUserApplicationController{

	private static Logger logger = Logger.getLogger(SCUserApplicationController.class.getName());
	
	@Autowired
	private SCUserApplicationDAO scUserApplicationDAO;
	
	@Get("show")
	public String show(Model model) {
	
		//MemuEnum
        model.add("MemuEnum",MemuEnum.scuser);
		return "/views/activity/sc/scUserApplicationList.vm";
	}

	@Post("getList")
	public String queryList(SCUserApplication userApplication) {
	
		JSONObject jo = new JSONObject();
		List<SCUserApplication> objs = scUserApplicationDAO.query(userApplication);
		
		for(SCUserApplication obj:objs)
		{
			obj.setNickname(Base64.getFromBase64(obj.getNickname()));
		}
		
		int size = scUserApplicationDAO.querysize(userApplication);
		
		jo.put("data", objs);
		jo.put("draw", userApplication.getDraw());
		jo.put("recordsTotal", size);
		jo.put("recordsFiltered", size);
		return "@"+jo.toString();
	}
}
